Playwright on Cloud Functions
microsoft/playwright: Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Fast and reliable end-to-end testing for modern web apps | Playwright
Gen1 では gcloud functions deploy に以下も渡す
--set-env-vars=PLAYWRIGHT_BROWSERS_PATH=0
--set-build-env-vars=PLAYWRIGHT_BROWSERS_PATH=0
Managing browser binaries​ - Browsers | Playwright
Gen2 では 要らない
~/.cache/ms-playwright 以下にインストールされる
Gen2 は Cloud Run なのでまるごとイメージになってる
Gen1 は workdir 以下だけイメージに入る感じかな、渡すことで node_modules 以下に入るようになる
2022/3/17 あれ? executable がみつからない、envvar 残っていたかな、gen2 でもつけたら確実
ビルド時にブラウザを入れる
code:package.json
{
...
"scripts": {
"prepare": "npx playwright install chromium"
}
}
メモリは 1GB ぐらいあてておく
#Cloud_Functions #GoogleCloud